﻿using System.Collections.Generic;
using YAXLib;

namespace RaytracerLib.Volumes
{
    public abstract class UnaryVolume : Volume
    {
        private Volume m_child_volume;

        protected UnaryVolume(Volume a_childVolume)
        {
            ChildVolume = a_childVolume;
        }

        public override IEnumerable<Volume> Children
        {
            get
            {
                yield return ChildVolume;
            }
        }

        [YAXNode]
        public Volume ChildVolume
        {
            get
            {
                return m_child_volume;
            }
            set
            {
                if (m_child_volume != null)
                    m_child_volume.Parent = null;
                m_child_volume = value;
                if (m_child_volume != null)
                    m_child_volume.Parent = this;
            }
        }
    }
}